package com.stellar.circle.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.stellar.circle.basic.dao.SChatMessageDao;
import com.stellar.circle.basic.entity.SChatMessage;
import com.stellar.circle.basic.service.SChatMessageService;
import com.stellar.circle.controller.admin.sChatMessage.vo.SChatMessageResponseVO;
import com.stellar.circle.convert.SChatMessageConvert;
import com.stellar.circle.handler.WebSocketHandler;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

/**
 * 私聊消息表(SChatMessage)服务实现
 *
 * @author Jqchan
 * @since 2025-06-12 21:21:20
 */
@Service
public class SChatMessageServiceImpl implements SChatMessageService {

    @Resource
    private SChatMessageDao sChatMessageDao;

    @Override
    public SChatMessage queryById(Long id) {
        return sChatMessageDao.queryById(id);
    }

    @Override
    public SChatMessage queryByCondition(SChatMessage condition) {
        return sChatMessageDao.queryByCondition(condition);
    }

    @Override
    public List<SChatMessage> queryAllByCondition(SChatMessage condition) {
        return sChatMessageDao.queryAllByCondition(condition);
    }

    @Override
    public List<SChatMessage> page(SChatMessage condition, int page, int pageSize) {
        return sChatMessageDao.page(condition, page, pageSize);
    }

    @Override
    public SChatMessage insert(SChatMessage entity) {
        sChatMessageDao.insert(entity);
        return entity;
    }

    @Override
    public int update(SChatMessage entity) {
        return sChatMessageDao.update(entity);
    }

    @Override
    public int deleteById(Long id) {
        return sChatMessageDao.deleteById(id);
    }

    @Override
    public Long count(SChatMessage condition) {
        return sChatMessageDao.count(condition);
    }

    @Override
    public void markAsRead(List<Long> messageId) {
        sChatMessageDao.markAsRead(messageId);
    }

    @Override
    public List<SChatMessage> selectHistory(String conversationId, Long lastMsgId, int limit) {
        return sChatMessageDao.selectHistory(conversationId, lastMsgId, limit);
    }

    @Override
    public List<SChatMessage> selectUnreadByUserId(Long userId) {
        return sChatMessageDao.selectUnreadByUserId(userId);
    }

    @Override
    public List<SChatMessageResponseVO> getMessageList(Long userId, int page, int pageSize) {
        return sChatMessageDao.getMessageList(userId, page, pageSize);
    }

    @Override
    public Long countChatList(Long userId) {
        return sChatMessageDao.countChatList(userId);
    }

}
